package com.sdp.right.task;

import java.time.LocalDate;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sdp.right.cron.ScheduledOfTask;
import com.sdp.right.db.sys_oper_log.service.ISysOperLogService;
import com.sdp.right.entity.SysOperLog;

@Component
public class CleanOperLogTask implements ScheduledOfTask{
	
	@Autowired
	private ISysOperLogService iSysOperLogService;

	@Transactional
	@Override
	public void execute() {
		//操作日志，最多保留120天
		LambdaQueryWrapper<SysOperLog> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.le(SysOperLog::getOperTime, LocalDate.now().plusDays(-120));
		iSysOperLogService.remove(queryWrapper);
		
	}

}
